package com.example.royalchef.utils;

import android.content.Context;

/**
 * Created by Administrator on 2017/5/7.
 * prefer方法工具类,用来存储简单键值对数据
 */

public class PreferUtils {
    /**
     * 存入数据
     *
     * @param key
     * @param values
     */
    public static void putString(String key, String values) {
        UIUtils.getContext().getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString(key, values).commit();
    }

    public static void putLong(String key, Long values) {
        UIUtils.getContext().getSharedPreferences("config", Context.MODE_PRIVATE).edit().putLong(key, values).commit();
    }

    public static void putBoolean(String key, Boolean values) {
        UIUtils.getContext().getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean(key, values).commit();
    }

    public static String getString(String key, String defaultValues) {
        String values = UIUtils.getContext().getSharedPreferences("config", Context.MODE_PRIVATE).getString(key, defaultValues);
        return values;
    }

    /**
     * 得到数据
     *
     * @param key
     * @param defaultBoolean
     * @return
     */
    public static boolean getBoolean(String key, boolean defaultBoolean) {
        boolean values = UIUtils.getContext().getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean(key, defaultBoolean);
        return values;
    }
}
